package jp.co.hcs.attendancemanagement.data.dao.impl;

import java.sql.SQLException;
import java.util.List;

import jp.co.hcs.attendancemanagement.data.dao.SubstituteHolidayActualDAO;
import jp.co.hcs.attendancemanagement.data.entity.SubstituteHolidayActual;
import jp.co.hcs.attendancemanagement.data.entity.ex.SubstituteHolidayActualExample;

public class SubstituteHolidayActualDAOImpl extends BaseDAOImpl implements SubstituteHolidayActualDAO {

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public SubstituteHolidayActualDAOImpl() {
        super();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int countSubstituteHolidayActualByExample(SubstituteHolidayActualExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("tb5_furikyu_jisseki.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int deleteSubstituteHolidayActualByExample(SubstituteHolidayActualExample example) throws SQLException {
        int rows = sqlMapClient.delete("tb5_furikyu_jisseki.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int deleteSubstituteHolidayActualByPrimaryKey(String substituteHolidayId) throws SQLException {
        SubstituteHolidayActual key = new SubstituteHolidayActual();
        key.setSubstituteHolidayId(substituteHolidayId);
        int rows = sqlMapClient.delete("tb5_furikyu_jisseki.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public void insertSubstituteHolidayActual(SubstituteHolidayActual record) throws SQLException {
        sqlMapClient.insert("tb5_furikyu_jisseki.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public void insertSubstituteHolidayActualSelective(SubstituteHolidayActual record) throws SQLException {
        sqlMapClient.insert("tb5_furikyu_jisseki.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    @SuppressWarnings("unchecked")
    public List<SubstituteHolidayActual> selectSubstituteHolidayActualByExample(SubstituteHolidayActualExample example) throws SQLException {
        List<SubstituteHolidayActual> list = sqlMapClient.queryForList("tb5_furikyu_jisseki.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public SubstituteHolidayActual selectSubstituteHolidayActualByPrimaryKey(String substituteHolidayId) throws SQLException {
        SubstituteHolidayActual key = new SubstituteHolidayActual();
        key.setSubstituteHolidayId(substituteHolidayId);
        SubstituteHolidayActual record = (SubstituteHolidayActual) sqlMapClient.queryForObject("tb5_furikyu_jisseki.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int updateSubstituteHolidayActualByExampleSelective(SubstituteHolidayActual record, SubstituteHolidayActualExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_furikyu_jisseki.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int updateSubstituteHolidayActualByExample(SubstituteHolidayActual record, SubstituteHolidayActualExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("tb5_furikyu_jisseki.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int updateSubstituteHolidayActualByPrimaryKeySelective(SubstituteHolidayActual record) throws SQLException {
        int rows = sqlMapClient.update("tb5_furikyu_jisseki.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    public int updateSubstituteHolidayActualByPrimaryKey(SubstituteHolidayActual record) throws SQLException {
        int rows = sqlMapClient.update("tb5_furikyu_jisseki.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }
    
	public String getOldestSubstituteLeaveNoByUserId(String userId) throws SQLException {
		return (String) sqlMapClient.queryForObject("tb5_furikyu_jisseki.getOldestSubstituteLeaveNoByUserId", userId);
	}
	
    public int deleteSubstituteLeaveTakingDayById(String substituteHolidayId) throws SQLException {
        int rows = sqlMapClient.update("tb5_furikyu_jisseki.deleteSubstituteLeaveTakingDayById", substituteHolidayId);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table tb5_furikyu_jisseki
     *
     * @ibatorgenerated Wed Mar 07 22:22:23 GMT+07:00 2012
     */
    private static class UpdateByExampleParms extends SubstituteHolidayActualExample {
        private Object record;

        public UpdateByExampleParms(Object record, SubstituteHolidayActualExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }

}